package fr.mmt.gisfizz.repository;

import fr.mmt.gisfizz.entity.User;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

/**
 * User repository.
 *
 * @author Mathieu MAST
 */
public interface UserRepository extends JpaRepository<User, String> {

    @Query("select e from User e WHERE lower(e.login) like :search OR lower(e.displayname) like :search")
    public Page<User> search(@Param("search") String search, Pageable page);

    public User findByLogin(String login);
}
